#ifndef SP_WORKER_H
#define SP_WORKER_H

#include <QObject>
#include <QSerialPort>
#include <QPointF>
#include <QFile>
typedef std::function<void(double,double,int,int)> GpggaData;

class SpWorker : public QObject
{
    Q_OBJECT
public:
    explicit SpWorker(QObject *parent = nullptr);
    ~SpWorker();

    bool isSpConnected();
    // 存储回调函数的变量
    GpggaData gpggaData;
    void setTxBuffer(const QByteArray &txBuffer);

signals:
    void SpResponse(const QString &s);
    void SpError(const QString &s);
//    void SpResponse(const QString &s);
    void response(const QString &s);
    void timeout(const QString &s);
    void SpGpsData(QPointF gpsPoi);
//    void gpggaData(double latitude, double longitude, int latDirection, int lonDirection);


public slots:
    void onNotifyConnectSP(const QString &s);
    void onNotifySend();

private slots:
    void onSpDataReadyRead();

private:
    QSerialPort *sp_ = nullptr;
    bool isSpConnected_ = false;

    QByteArray rxBuffer_;
    QByteArray txBuffer_;
};

#endif // SP_WORKER_H
